package com.zygh.policeasset.controller;

import com.zygh.policeasset.component.CommonResult;
import com.zygh.policeasset.mapper.AuditFlowMapper;
import com.zygh.policeasset.pojo.ShortcutMenu;
import com.zygh.policeasset.service.AssetsService;
import com.zygh.policeasset.service.BasicsService;
import com.zygh.policeasset.service.CompletedSerivce;
import com.zygh.policeasset.service.ContractService;
import com.zygh.policeasset.service.DailyProjectService;
import com.zygh.policeasset.service.FinalStatementService;
import com.zygh.policeasset.service.HardwitService;
import com.zygh.policeasset.service.PurchaseService;
import com.zygh.policeasset.service.SettlementService;
import com.zygh.policeasset.service.ShortcutMenuService;
import com.zygh.policeasset.service.SoftwitService;
import com.zygh.policeasset.service.TenderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping({"/homePage"})
@Api(tags = {"首页管理"})
@RestController
/* loaded from: police-asset-2.0-0.0.1-SNAPSHOT.jar:BOOT-INF/classes/com/zygh/policeasset/controller/HomePageController.class */
public class HomePageController {
    @Autowired
    AssetsService assetsService;
    @Autowired
    ShortcutMenuService shortcutMenuService;
    @Autowired
    TenderService tenderService;
    @Autowired
    ContractService contractService;
    @Autowired
    CompletedSerivce completedSerivce;
    @Autowired
    SettlementService settlementService;
    @Autowired
    FinalStatementService finalStatementService;
    @Autowired
    PurchaseService purchaseService;
    @Autowired
    BasicsService basicsService;
    @Autowired
    SoftwitService softwitService;
    @Autowired
    HardwitService hardwitService;
    @Autowired
    DailyProjectService dailyProjectService;
    @Autowired
    AuditFlowMapper auditFlowMapper;

    @RequestMapping(value = {"/getData"}, method = {RequestMethod.GET})
    @ApiOperation("数据展示")
    public Object getData(@RequestHeader("roleId") Integer roleId) {
        if (roleId.intValue() == 9) {
            return new CommonResult().success();
        }
        try {
            JSONObject json = new JSONObject();
            CompletableFuture<JSONObject> assetsTotalTop = this.assetsService.getTotal();
            CompletableFuture<JSONObject> assetsTotalDown = this.assetsService.getMonthTotal();
            CompletableFuture<JSONArray> getAssetsTypeSumListOne = this.assetsService.getAssetsTypeSumListOne();
            CompletableFuture<JSONArray> getAssetsTypeSumListTwo = this.assetsService.getAssetsTypeSumListTwo();
            CompletableFuture<List<ShortcutMenu>> shortcutMenuList = this.shortcutMenuService.selectList();
            CompletableFuture<JSONArray> assetsSelfBuilt = this.assetsService.getAssetsSelfBuilt();
            CompletableFuture<JSONArray> assetsLifeCycle = this.assetsService.getAssetsLifeCycle();
            if (assetsTotalTop != null) {
                json.put("getTotal", assetsTotalTop.get());
            }
            if (assetsTotalDown != null) {
                json.put("getMonthTotal", assetsTotalDown.get());
            }
            if (getAssetsTypeSumListOne != null) {
                json.put("getAssetsTypeSumListOneNumber", getAssetsTypeSumListOne.get().getJSONArray(0));
                json.put("getAssetsTypeSumListOneAmount", getAssetsTypeSumListOne.get().getJSONArray(1));
            }
            if (getAssetsTypeSumListTwo != null) {
                json.put("getAssetsTypeSumListTwoNumber", getAssetsTypeSumListTwo.get().getJSONArray(0));
                json.put("getAssetsTypeSumListTwoAmount", getAssetsTypeSumListTwo.get().getJSONArray(1));
            }
            if (shortcutMenuList != null) {
                json.put("shortcutMenuList", shortcutMenuList.get());
            }
            if (assetsSelfBuilt != null) {
                json.put("assetsSelfBuilt", assetsSelfBuilt.get());
            }
            if (assetsLifeCycle != null) {
                json.put("assetsLifeCycle", assetsLifeCycle.get());
            }
            return new CommonResult().success(json);
        } catch (Exception e) {
            e.printStackTrace();
            return new CommonResult().validateFailed(e.toString());
        }
    }

    @RequestMapping(value = {"/getMonthList"}, method = {RequestMethod.GET})
    @ApiOperation("本月新增资产")
    public Object getMonthList(@RequestParam(defaultValue = "1", value = "pageNum") int pageNum, @RequestParam(defaultValue = "10", value = "pageSize") int pageSize) {
        return this.assetsService.getMonthList(pageNum, pageSize);
    }

    @RequestMapping(value = {"/push"}, method = {RequestMethod.GET})
    public Object push(@RequestParam("userId") Integer userId) {
        return this.auditFlowMapper.queryAuditCount(userId, 2);
    }
}